﻿@{
    ViewBag.Title = "模型列表";
    Layout = "~/Views/Shared/_Main.cshtml";
}
@section Head{
    <script src="/Scripts/date.format.js" type="text/javascript"></script>
    <script type="text/javascript">
        var clickAll = true;
        var UrlArray = $.getUrlArray();
        var retArr = new Array();
        var ExpIDs = new Array();
        var opts = {
            rows: 10,
            height: 450,
            url: "/ViewGroup/GetModelList",
            para: { systemID: UrlArray["systemID"], dbName: encodeURI(UrlArray["dbName"]) },
            idField: "Guid",
            checkbox: true,
            columns: [
                    { field: 'MDP_ViewName', title: '模型名称', width: 45, sortable: true },
                    { field: 'ViewDescription', title: '模型描述', width: 45, sortable: true }, 
                    {field: 'CreateTime', title: '创建时间', width: 10, align: 'center', sortable: true }
                    ],
            OnChickRow: function (value, rowData, rowIndex) {
                return clickRow(value, rowData, rowIndex, true);
            }
        };
        function clickRow(value, rowData, rowIndex, load) {
            var s = true;
            if (s) {
                $("#sel_content").append("<span class='s1 s1" + value + "'><a title='" + rowData.ViewDescription + "'>" + rowData.MDP_ViewName + "</a><span class='s2 s2" + value + "''>&nbsp;X&nbsp;</span></span>");
                $(".s2" + value).bind("click", function () {
                    $(".s1" + value).remove();
                    $(".s2" + value).remove();
                    for (var j = 0; j < retArr.length; j++) {
                        if (retArr[j].Guid == value) {
                            retArr.removeAt(j);
                        }
                    }
                    ExpIDs.removeValue(value);
                    opts.para["ExpIDs"] = ExpIDs.join(",");
                    initTable("DataGrid2", opts);
                });
                retArr.push(rowData);
                ExpIDs.push(value);
                if (load) {
                    opts.para["ExpIDs"] = ExpIDs.join(",");
                    initTable("DataGrid2", opts);
                } 
            }
            return true;
        }
        $(function () {
            page_Init(); 
            InitList();
        });
        function page_Init() {
            $("body").css("overflow", "hidden");
        }

        function DoAction(i, v) {
            var arr = new Array();
            arr.push(i);
            arr.push(v);
            returnParent(arr);
        }
        function InitList() {
            opts.para["tableName"] = $("#txt_TableName").val();
            $("#DataGrid2").dg(opts);
        }
        function btnSearch() {
            thisPageNum = 1;
            InitList();
        }
        function flexiSelect() {
            if (retArr.length < 1) {
                alert('请选择一条数据!');
                return false;
            }
            returnParent(retArr);
            return false;
        }
    </script>
}
<div style="height: 470px; padding-left: 5px; padding-right: 5px; overflow: hidden;
    overflow-y: scroll;">
    <table class="listTitle">
        <tr>
            <td width="15">
                <img src="/images/search.png" />
            </td>
            <td width="300">
                模型配置搜索
            </td>
            <td align="right">
            </td>
        </tr>
    </table>
    <table class="searchArea" width="100%">
        <tr>
            <td>
                模型名称：
                <input type="text" id="txt_TableName" style="width: 300px;" />
                <input type="button" value="搜索" class="button" onclick="btnSearch()" />
            </td>
        </tr>
    </table>
    <table id="selected" style="width: 100%;">
        <tr>
            <td width="50">
                已选择：
            </td>
            <td>
                <div id="sel_content">
                </div>
            </td>
            <td width="50">
                <input type="button" value=" 确定 " class="button" onclick="flexiSelect()" />
            </td>
        </tr>
    </table>
    <table class="listTitle">
        <tr>
            <td width="15">
                <img src="/images/filesave.png" />
            </td>
            <td width="300">
                模型配置列表<span id="type_Name"></span>
            </td>
            <td align="right">
            </td>
        </tr>
    </table>
    <table id="DataGrid2" class="pagTable" cellpadding="0" cellspacing="0">
    </table>
    <div>
        <div id="Pagination" class="pagination">
        </div>
        <div id="loading" class="loading">
            <img src="/Images/tree_loading.gif" />
        </div>
    </div>
    <div id="msg">
    </div>
</div>
